home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
lisp
/
eulisp
/
mpfeel.lha
/
MPFeel
/
Plurals
/
Modules
/
lib.em
< prev
next >
Wrap
Lisp/Scheme
|
1992-06-03
|
2KB
|
56 lines
(defmodule lib (ppl ppl-ll standard0 plural) ()
(depfun null (o) (if o () t))
(depfun list-length (l) (if (null l) 0 (+ 1 (list-length (cdr l)))))
(depfun list-ref (l i) (if (null l) ()
(if (eq i 0) (car l)
(list-ref (cdr l) (- i 1)))))
(depfun tail (l)
(if (null l) ()
(if (null (cdr l)) l (tail (cdr l)))))
(depfun append (front rest)
(let ((front-end (tail front)))
(if (null front-end) rest
(progn
((setter cdr) front-end rest)
front))))
(depfun convert-internal (d v i)
(if (null d) v
(progn
(convert-internal (cdr d) v (- i 1))
((setter vector-ref) v i (car d)) v)))
(depfun convert (l)
(let ((l-l (list-length l)))
(convert-internal l (make-vector l-l) (- l-l 1))))
(defun any (l)
; returns t if l contains at leats 1 non-nil element
(if l (if (car l) t (any (cdr l))) ()))
(defun args-left-p (args)
; each arg is a plural containing a list, if any of these lists contains
; a null then there are no more args for parallel mapcar
; (mapcar (lambda (o) (format t "\n ~a" (allocate-xec The-Context o))) args)
; (format t "\n")
(not (any (mapcar (lambda (o) (let ((status (mp-if The-Context
(mp-not The-Context o))))
(mp-fi The-Context) status)) args))))
(defun l-mapcar (fn args)
(if (not (args-left-p args)) (mp-bang The-Context ())
(mp-cons The-Context (apply fn (mapcar PF-car args))
(l-mapcar fn (mapcar PF-cdr args)))))
(defun PF-mapcar (fn . args) (l-mapcar fn args))
(add-pfun 'mapcar 'PF-mapcar '(fn . args))
(export PF-mapcar)
)